/**
 * 
 */
package org.myontology.controller.impl;

import org.myontology.controller.AbstractAction;
import org.myontology.controller.Action;
import org.myontology.controller.AttributeHolder;
import org.myontology.controller.SesameSession;
import org.myontology.controller.rules.SimpleRuleEngine;
import org.myontology.users.Login;

/**
 *  @author <a href="michael.hackl@sti2.at">Michael Hackl</a>
 * Project: Myontology - www.myontology.org
 * STI
 */
public class DiscussionAddAction extends AbstractAction implements Action {

	private SimpleRuleEngine rules;
	private SesameSession session;
	
	
	/* (non-Javadoc)
	 * @see org.myontology.controller.Action#execute(org.myontology.controller.AttributeHolder)
	 */
	public void execute(AttributeHolder attributes) throws Exception {
		String title = attributes.getRequestParameter("title");
		String content = attributes.getRequestParameter("content");
		
		Discussion d = new Discussion();
		d.id.addValue(System.currentTimeMillis()+"");
		d.title.addValue(title);
		d.content.addValue(content);
		d.isfor.addValue(DiscussionAction.URI.getValue(attributes));
		d.author.addValue(Login.CURRENT_USER.getValue(attributes));
		session.update(d);
		new DiscussionAction(rules,session).execute(attributes);
	}

	

	
}
